package org.sag.faultlocalization;

import org.sag.coverage.PolicyCoverageFactory;
import org.sag.coverage.PolicySpreadSheetTestSuite;

public class FaultLocalizationDemoKmarketSpreadsheetTests_old {

	
	public static void main(String[] args) throws Exception{
//		int a00=101, a01=0, a10=1179, a11=2648;
//		System.out.println((double)(a11*a00)/Math.sqrt((double)(a11+a10)*(a00+a01)*(a11+a01)*(a10+a00)));
		
		// Policies, tests and mutants
		String[] policy = { "kmarket-blue-policy",  "kmarket-sliver-policy",  "kmarket-gold-policy", "conference3", "fedora-rule3", 
				"itrust3", "itrust3-5", "itrust3-10", "itrust3-20", "conference3_CRE1"};
		String[] testsuite = {"Basic", "Exclusive", "Pair", "PDpair", "DecisionCoverage", "MCDCCoverage", "RuleLevel"};
		int policyNumber = 9; 
		int testsuiteNumber = 5; // 5 for MCDC Coverage - strongest.
		String mutantIndex = "RTF15";
		/* Specify coverage level */
		int coverageLevel = 0; // 0 - FIREABLE, 1 - REACHABLE, 2 - ADJUSTED WEIGHT REACHABLE
		
		String testSuiteSpreadSheetFile = "Experiments//" + policy[policyNumber]+ "//test_suites//" 
				+ policy[policyNumber] + "_" + testsuite[testsuiteNumber] + "//" + policy[policyNumber] 
						+ "_" + testsuite[testsuiteNumber] + ".xls";
//		String policyMutantSpreadsheetFile = "Experiments//" + policy[policyNumber] + "//mutants//" 
//						+ policy[policyNumber] + "_mutants.xls";
		String policyMutantFile = "Experiments//" + policy[policyNumber] + "//mutants//"
						+ policy[policyNumber] + "_" + mutantIndex + ".xml";
		String mutantResultFileName = "Experiments//" + policy[policyNumber] + "//fault-localization//" 
						+ policy[policyNumber] + "_" + mutantIndex + "_" + testsuite[testsuiteNumber] 
						+ "_lev" + coverageLevel + ".xls";
		
		// TODO: - to examine the details of naish2
		PolicySpreadSheetTestSuite testSuite = 
				new PolicySpreadSheetTestSuite(testSuiteSpreadSheetFile, policyMutantFile);
		testSuite.runAllTests();
		System.out.println("\n");
//		testSuite.generateJUnitFile("//Users//dianxiangxu//Documents//JavaProjects//WSO2-XACML//XPA//src", 
		testSuite.generateJUnitFile("src", 
				"org.sag.faultlocalization", "KmarketGeneratedTests");
		PolicyCoverageFactory.writeCoverageToSpreadSheet(mutantResultFileName);
		
		for (SpectrumBasedDiagnosisResults results: SpectrumBasedFaultLocalizer.applyAllFaultLocalizers(coverageLevel)){
			results.printCoefficients();
		}
		System.out.println("Spectrum Result written in " + mutantResultFileName);
	}

}